Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitignore-globs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitignore-globs

Parse a .gitignore file into an array of glob patterns.

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

gitignore-globs

Parse a .gitignore file into an array of glob patterns.

Usage

.gitignore:

node_modules
package.json

index.js:

var parse = require('gitignore-globs');

var globs = parse('.gitignore');

console.log(globs);
// Result: ['node_modules', '**/node_modules/**', 'package.json']

API

parse([filepath], [options])

  • filepath (string; default: process.cwd() + '.gitignore') - Path to your .gitignore.
  • options (array) - Options see below.
Options:
{
    negate: false
}
  • negate (bool; default: false) - Option to negated patterns. Example: package.json => !package.json

Rules

  • Git: http://git-scm.com/docs/gitignore#_pattern_format
  • Glob: https://github.com/isaacs/node-glob#glob-primer

Mappings:

.gitignoreDescriptionGlob
#Commentignore
Blank lineignore
/fooIgnore root (not sub) file and dir and its paths underneath./foo, /foo/**
/foo/Ignore root (not sub) foo dir and its paths underneath./foo/**
fooIgnore (root/sub) foo files and dirs and their paths underneath.foo, **/foo/**
foo/Ignore (root/sub) foo dirs and their paths underneath.**/foo/**

Other patterns already work as globs. For example:

  • *.zip: Ignore any zip file.
  • .DS_Store: Ignore all .DS_Store files.
  • *~: Ignore all files that end with a tilde.
  • *.[oa]: Ignore any files ending in ".o" or ".a", for example archive.a or bar.o.
  • *: Ignore all files.

Test

npm test

Watch:

npm run watch-test

or

nodemon --exec "mocha" test --exclude "node_modules"

Resources

License

MIT © Bernhard Wanger, Sevenweb

Keywords

FAQs

Package last updated on 27 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc